package com.net.shop.car.manager.api.volley.response;

import org.json.JSONException;
import org.json.JSONObject;

import com.net.shop.car.manager.api.model.Member;
import com.net.shop.car.manager.api.volley.Response;
import com.net.shop.car.manager.utils.Constants;
import com.net.shop.car.manager.utils.LogUtils;
import com.net.shop.car.manager.utils.StringUtils;

/**
 * @author Deve
 *
 */
public class LoginResponse extends Response {

	private Member user;
	/**
	 * @param type
	 */
	public LoginResponse() {
		super(Constants.LOGIN);
	}

	@Override
	public String getContentTag() {
		return "memberinfo";
	}
	
	@Override
	public void parseContent(String content) {
		try {
			user = new Member();
			JSONObject jsonObject = new JSONObject(content);
			user.setName(StringUtils.filterNull(jsonObject.getString("NAME")));
			user.setVb(jsonObject.getInt("VB"));
			user.setMobile(StringUtils.filterNull(jsonObject.getString("MOBILE")));
			user.setMemberId(StringUtils.filterNull(jsonObject.getString("ID")));
			user.setPicUrl(StringUtils.filterNull(jsonObject.getString("HEAD_PIC")));
		} catch (JSONException e) {
			LogUtils.e(e.getMessage());
		}
	}

	public Member getUser() {
		return user;
	}
}
